<%@page import="java.text.SimpleDateFormat"%>
<%@ page import="java.util.*"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<link href="dist/css/starter-template.css" rel="stylesheet">
<html>
<body>
	<%
		Calendar cal = Calendar.getInstance();
		Date dt = new Date();

		SimpleDateFormat sdf = new SimpleDateFormat("dd");

		int selDate = Integer.parseInt(sdf.format(dt));

		sdf = new SimpleDateFormat("MMM , yyyy");

		String str = request.getParameter("selectedDate");
		if (str != null)
			selDate = Integer.parseInt(str);
	%>
	<div class="container">
		<h3>Select the people worked/working from home</h3>
		<h4><%=sdf.format(dt)%></h4>
		<div class="list">
			<ul class="pagination pagination-sm">
				<!-- <li ><a href="#">&laquo;</a></li> -->
				<%
					for (int i = 1; i <= cal.getActualMaximum(Calendar.DAY_OF_MONTH); i++) {
						if (i == selDate) {
				%>
				<li class="active"><a href="#"><%=selDate%> <span
						class="sr-only">(current)</span></a></li>
				<%
					} else {
				%>
				<li><a href="showWorkFromHomeScreen?selectedDate=<%=i%>"><%=i%></a></li>
				<%
					}
					}
				%>

				<!-- <li><a href="#">&raquo;</a></li> -->
			</ul>
		</div>
		<hr>
		<form action="workFromHome.action" method="post">
			<%
				session.setAttribute("selectedDate", selDate);
			%>
			<div style="overflow: auto; height: 400px;">
				<table align="left">
					<s:iterator value="#session.allUsersInArray" var="row">
						<tr>
							<s:iterator value="row" var="x">
								<c:if test="${x != null}">
									<c:if test="${x.workFromHome == false}">
										<td><label class="checkbox"> <input
												type="checkbox" name="checkboxes"
												value="<s:property value="id"/>"> <s:property
													value="firstname" /> <s:property value="lastname" />
										</label></td>
									</c:if>
									<c:if test="${x.workFromHome == true}">
										<td><label class="checkbox"> <input
												type="checkbox" checked="checked" name="checkboxes"
												value="<s:property value="id"/>"> <s:property
													value="firstname" /> <s:property value="lastname" />
										</label></td>
									</c:if>
								</c:if>
							</s:iterator>
						</tr>
					</s:iterator>
					<tr>
						<td colspan="2"><br></td>
					</tr>
					<tr>
						<td colspan="2" align="right"></td>
					</tr>
				</table>
			</div>
			<div class="submitButton">
				<button class="btn btn-lg btn-primary btn-block" type="submit">Update</button>
			</div>
		</form>
	</div>
</body>
<script src="dist/js/bootstrap.js"></script>
</html>